package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.OrderReturnApply;
import com.drug.mingkang.Mapper.OrderReturnApplyMapper;
import com.drug.mingkang.service.OrderReturnApplyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 退货订单表(OrderReturnApply)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:44
 */
@Service("orderReturnApplyService")
public class OrderReturnApplyServiceImpl implements OrderReturnApplyService {
    @Resource
    private OrderReturnApplyMapper orderReturnApplyMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param orderId 主键
     * @return 实例对象
     */
    @Override
    public OrderReturnApply queryById(String orderId) {
        return this.orderReturnApplyMapper.queryById(orderId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<OrderReturnApply> queryAllByLimit(int offset, int limit) {
        return this.orderReturnApplyMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param orderReturnApply 实例对象
     * @return 实例对象
     */
    @Override
    public OrderReturnApply insert(OrderReturnApply orderReturnApply) {
        this.orderReturnApplyMapper.insert(orderReturnApply);
        return orderReturnApply;
    }

    /**
     * 修改数据
     *
     * @param orderReturnApply 实例对象
     * @return 实例对象
     */
    @Override
    public OrderReturnApply update(OrderReturnApply orderReturnApply) {
        this.orderReturnApplyMapper.update(orderReturnApply);
        return this.queryById(orderReturnApply.getOrderId());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String orderId) {
        return this.orderReturnApplyMapper.deleteById(orderId) > 0;
    }
}